let nameEle = document.querySelector('input[name="name"]')
let passwordEle = document.querySelector('input[name="password"]')
let confirmPasswordEle = document.querySelector('input[name="confirmPassword"]')
let butEle = document.querySelector("button")
let inputEle = document.querySelectorAll("input")

let username = document.querySelector(".username")
let userpassword = document.querySelector(".userpassword")
let confPassword = document.querySelector(".confPassword")

let loginData = localStorage.getItem('USER')
let loginArr = JSON.parse(loginData) || []
console.log(loginArr);




// 点击登录事假
butEle.addEventListener("click", function (e) {
            e = e || window.event
            if (nameEle.value == "" || passwordEle.value == "")
                return alert("填写信息不完整，请确认！")
            if (nameEle.value !== loginArr.nv&&passwordEle.value !== loginArr.pv) {
                username.innerHTML = "账户名或密码输入有误"
                return false}
                location.href = "../pages/index.html"
            })

        // 用户名失焦事件
        nameEle.onblur = function (e) {
            nameContent()
        }

        function nameContent() {
            if (nameEle.value == "") {
                username.innerHTML = "账户名不能为空"
                return false
            } else {
                nameEle.innerHTML = ""
                return true
            }
        }


        // 密码框失焦事件
        passwordEle.onblur = function () {
            if (passwordContent() == false) {
                return
            }

            function passwordContent() {
                if (passwordEle.value == "") {
                    userpassword.innerHTML = "密码不能为空"
                    return false
                } else {
                    passwordEle.innerHTML = ""
                    return true
                }
            }
        }